package com.ctrl.riveradministrator.mvp.view.activity.trace.search;

import android.content.Context;
import android.graphics.Color;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ctrl.riveradministrator.R;
import com.ctrl.riveradministrator.base.BaseActivity;
import com.ctrl.riveradministrator.base.BasePresenter;
import com.ctrl.riveradministrator.mvp.model.Task;

public class DetailActivity extends BaseActivity {

    private Toolbar toolbar;
    private TextView titleTv;
    private ImageView leftMenu;

    private Task task;

    private TextView name, kssj, jssj, kswd, ksjd, jswd, jsjd, sf, tq, dw, nr, qy, zg;

    @Override
    protected void initParams(Bundle parms) {

    }

    @Override
    protected int bindLayout() {
        return R.layout.activity_detail;
    }

    @Override
    protected void initView(View view) {
        toolbar = (Toolbar) $(R.id.toolbar);
        titleTv = (TextView) $(R.id.title_tv);
        leftMenu = (ImageView) $(R.id.left_iv);
        name = (TextView) $(R.id.name);
        kssj = (TextView) $(R.id.kssj);
        jssj = (TextView) $(R.id.jssj);
        kswd = (TextView) $(R.id.kswd);
        ksjd = (TextView) $(R.id.ksjd);
        jswd = (TextView) $(R.id.jswd);
        jsjd = (TextView) $(R.id.jsjd);
        sf = (TextView) $(R.id.sf);
        tq = (TextView) $(R.id.tq);
        dw = (TextView) $(R.id.dw);
        nr = (TextView) $(R.id.nr);
        qy = (TextView) $(R.id.qy);
        zg = (TextView) $(R.id.zg);

        task = (Task) getIntent().getSerializableExtra("task");

        /*
         * 设置toolbar
         * */
        toolbar.setTitleTextColor(Color.WHITE);
        toolbar.setTitle("");
        titleTv.setText("巡河详细信息");
        leftMenu.setBackground(getDrawable(R.drawable.ic_chevron_left_24dp));
    }

    @Override
    protected void doBusiness(Context mContext) {
        name.setText(task.getPatrolName());
        kssj.setText(task.getStartTime());
        jssj.setText(task.getEndTime());
        kswd.setText(task.getStartLatitude());
        ksjd.setText(task.getStartLongitude());
        jswd.setText(task.getEndLatitude());
        jsjd.setText(task.getEndLongitude());
        if (task.getPatrolState().equals("1")) {
            sf.setText("正在巡河");
        } else {
            sf.setText("正常巡河");
        }
        tq.setText(task.getWeather());
        dw.setText(task.getUnit());
        nr.setText(task.getContent());
        qy.setText(task.getQuyu());
        zg.setText(task.getLastcase());
    }

    @Override
    protected void widgetClick(View view) {
        switch (view.getId()) {
            case R.id.left_iv:
                finish();
                break;
        }
    }

    @Override
    protected void setListener() {
        leftMenu.setOnClickListener(this);
    }

    @Override
    public void handleMessage(Message message, int what) {

    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }
}
